package com.ftg.learn.mapper;

import com.ftg.learn.domain.DemoDomain;
import org.apache.ibatis.annotations.*;
import org.springframework.web.bind.annotation.DeleteMapping;

import java.util.List;

/**
 * @author kangjx
 * @date 2024/1/29
 */
@Mapper
public interface DemoMapper {

    /**
     * 查询所有数据
     * @return List
     */
    List<DemoDomain> showDemo(@Param("name") String name,@Param("start") long start,@Param("pageSize") long pageSize);


    /**
     * 用来查询总记录，给列表的分页功能有
     * @param name 查询
     * @return int
     */
    long demoCount(@Param("name") String name);

    /**
     * 插入数据
     * @param domain  实体类
     * @return int
     */
    @Insert("insert into demo(name,age,address) values(#{name},#{age},#{address})")
    int insertDemo(DemoDomain domain);

    /**
     * 根据id查询
     * @param id id
     * @return DemoDomain
     */
    @Select("select * from demo where id = #{id}")
    DemoDomain findOneById(@Param("id") Integer id);

    /**
     * 根据id删除
     * @param id id
     * @return int
     */
    @Delete("delete from demo where id = #{id}")
    Integer deleteById(@Param("id") Integer id);

    Integer update(DemoDomain domain);
}
